﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace XFControls.XFPanels.XFPanelItems
{
    public class XFButton : IXFButton
    {
        private int _height = 40;
        private int _width = 40;

        #region IXFButton Members

        public event EventHandler Clicked;
        public XFPanelBase Parent { get; set; }

        public void Click()
        {
            if (Clicked != null)
                Clicked(this, new EventArgs());
        }

        public void ButtonPaint(Graphics g, int x, int y)
        {
            using (SolidBrush b = new SolidBrush(Color.HotPink))
                g.FillRectangle(b, x, y, _width, _height);
        }

        public int Width
        {
            get
            {
                return _width;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public int Height
        {
            get
            {
                return _height;
            }
            set
            {
                throw new NotImplementedException();
            }
        }
        #endregion
    }

    public class XFButtonHome : IXFButton
    {
        private int _height = 40;
        private int _width = 40;

        #region IXFButton Members

        public int Width
        {
            get
            {
                return _width;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public int Height
        {
            get
            {
                return _height;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public event EventHandler Clicked;
        public XFPanelBase Parent { get; set; }

        public void Click()
        {
            if (Clicked != null)
                Clicked(this, new EventArgs());

            if (Parent == null)
                return;

            if (Parent is XFPanelHeader)
            {
                var mp = ((XFPanelHeader)Parent).MainPanelContainer;

                if (mp.MainPanel.Height < Screen.PrimaryScreen.WorkingArea.Height)
                    mp.MainPanel.Height = Screen.PrimaryScreen.WorkingArea.Height;

                var home = new XFPanelHome();
                mp.MainPanel.SetLeftPanel(home);
                mp.MainPanel.EnableSlide();

                mp.Header.LeftButton = null;
            }
        }

        public void ButtonPaint(Graphics g, int x, int y)
        {
            this.DrawUI("house_alpha", g, new Rectangle(x, y, _width, _height));
        }

        #endregion
    }

}
